/***
 * Copyright (c) 2021-2031 murenchao
 * fig is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *       http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package cool.taomu.software.fig.configure.entity

import java.util.List
import org.eclipse.xtend.lib.annotations.Accessors
import org.eclipse.xtend.lib.annotations.ToString

@Accessors
@ToString
class ConfigureEntity {
    @Accessors
    @ToString
    static class Ssl {
        boolean useClientCA;
        String keyStoreType;
        String keyFilePath;
        String managerPwd;
        String storePwd;
    }

    @Accessors
    @ToString
    static class Mqtt {
        // 是否允许匿名登陆
        boolean anonymous = true;
        String username;
        String password;
        // 服务消息
        String ip = "0.0.0.0";
        Integer port = 1883;
        boolean useSsl = false;
        Ssl ssl;
        List<Rpc> cluster;
    }

    @Accessors
    @ToString
    static class Host {
        String ip = "0.0.0.0";
        Integer port;

        new() {
        }

        new(String ip, Integer port) {
            this.ip = ip;
            this.port = port;
        }
    }

    @Accessors
    @ToString
    static class Rpc {
        String ip = "0.0.0.0";
        Integer port = 32768;
    }

    @Accessors
    @ToString
    static class ObjectPool {
        Integer maxTotalPerKey = 10;
        Integer maxIdlePerKey = 10;
        Integer minIdlePerKey = 5;
        boolean lifo = false;
    }

    @Accessors
    @ToString
    static class JedisConfig {
        List<Host> cluster;
        String username;
        String password;
        Integer maxIdle;
        Integer minIdle;
        Integer maxTotal;
        Integer timeout = 5000;
        Integer maxAttempts = 5;
        boolean testOnBorrow = true;
        boolean testOnReturn = false;
    }

    @Accessors
    @ToString
    static class Cache {
        Integer capacity = 100;
        Integer maximumSize = 1000;
        JedisConfig jedis;
    }

    Mqtt mqtt = new Mqtt();
    Rpc rpc = new Rpc();
    ObjectPool pool = new ObjectPool();
    Cache cache = new Cache();
    Host ntp = new Host("None",123);
}
